<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>经销商问题答案管理</title>
    <link rel="stylesheet" type="text/css" href="../../themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../css/default.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../js/datagrid-detailview.js"></script>
    <script type="text/javascript" src="../../js/datagrid-cellediting.js"></script>
    <script type="text/javascript" src="../../js/jquery-form.js"></script>
    <script type="text/javascript" src="../../js/app.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <script type="text/javascript" src="../../js/comm_check.js"></script>
    <script type="text/javascript" src="../../js/relax_function.js"></script>
    

</head>
<body>
    <!-- 查询条件 -->
    <div id="searchbar">
            <fieldset>
                <legend>查询条件</legend>
                    <table id="tblSearch" cellpadding="0" cellspacing="0" border="0" class="tbl-border">
                        <tr>
                           <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">问题标题：</label></td>
	                       <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="contentSerch" name="content"></input></td>
                           <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">经销商名称：</label></td>
	                       <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="dealerNameSerch" name="dealerName"></input></td>
	                       <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">问题答案：</label></td>
	                       <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="dealerAnswerSerch" name="dealerTel"></input></td>
                        	<td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">问题类型：</label></td>
                            <td class="tbl-td-border"> 
                         	‍‍<select class="easyui-combobox tbl-input-left"  id="questionTypeSerch" name = "type">
                                <option value="" selected="selected">全部</option>
								<option value="0">单选</option>
								<option value="1">多选</option>
								<option value="2">简答题</option>
                         	</select>
                         </td>
                        </tr>
                    </table>
	                    <div style="padding: 5px; text-align: center;">
	                        <a href="#" class="easyui-linkbutton" icon="icon-search" onclick="loadVisitAnswerPage()">查询</a>
	                         <a href="javascript:void(0)" class="easyui-linkbutton" icon="icon-reload" id="resetSearch">重置</a>
	                    </div>
            </fieldset>
    </div>

    <!-- 用户信息 -->
    <table  id="dg_cr" class="easyui-datagrid">
    </table>
    
<!-- 工具栏 -->
<div id="toolbar">
	    <!-- <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="updateIsNormal()" >人工拜访</a> -->
		<!--进度条-->
		<div id="div_pb" style="position: absolute; width: 400px; height: 50px; right: 20%; left: 25%; top: 35%; bottom: 20%; margin-left: 50px; margin-top: 25px; display: none; text-align: center;">
	    	<img src="../../images/loading.gif" />
		</div>
</div>
    <script type="text/javascript">
    
    	var size = 10;
    	var page = 1;
        var conf = {
              options: {
                singleSelect: false,
                ctrlSelect: true,
                showFooter: true,
                fit: true,
                fitColumns: true,
                checkOnSelect: false,
                selectOnCheck: false,
                footer: '#toolbar',
                toolbar: '#searchbar',
                striped: true,
                
                columns: [[
                    {field: 'ck', checkbox: true},
                    {field: 'id', title: '问题答案id',  align: 'left', halign: 'center',hidden:true},
                    {field: 'content', title: '问题标题',  align: 'left', halign: 'center'},
                    {field: 'dealerId', title: '经销商id',  align: 'left', halign: 'center',hidden:true},
                    {field: 'dealerName', title: '经销商名称',  align: 'left', halign: 'center'},
                    {field: 'type', title: '问题类型',  align: 'left', halign: 'center',
                    	formatter: function(value, row, index) {
                            if(value == '0') {
                                 return "单选";
                            } 
                            if(value == '1') {
                                 return "多选";
                            }
                            if(value == '2') {
                                 return "简答题";
                            }
                        }   
                    },
                    {field: 'answer', title: '经销商答案',  align: 'left', halign: 'center',
                    	formatter: function(value, row, index) {
                    		return '<font color="red">' + value + '</font>';
                        }   
                    },
                    {field: 'options', title: '问题选项',  align: 'left', halign: 'center'},
                    {field: 'visitId', title: '拜访id',  align: 'left', halign: 'center',hidden:true}
                    
                ]],
                pagination: true,
                pageSize: size,
                pageList: [size * 1, size * 2, size * 3, size * 5],
                pageNumber: 1,
                rownumbers: true,
                onAfterEdit: function (rowIndex, rowData, changes) {
                },
                rowStyler: function (index, row) {
                }
            }
        }; 
        
        $(function () {
            $('#pb').progressbar({
                onChange: function (value) {
                    $('.progressbar-value').css('background-color', 'red');
                }
            });
            $('#dg_cr').datagrid({footer: '#toolbar'}).datagrid('subgrid', conf);
            loadVisitAnswerPage(page, size);
            $('#dg_cr').datagrid('getPager').pagination({
                loadMsg: '正在加载数据...',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',
                onSelectPage: function (page, size) {
                	loadVisitAnswerPage(page, size);

                }
            });
        });
        function loadVisitAnswerPage(page,size) {
        	page = page || 1;
            size = size || 10;
            $('#dg_cr').datagrid("loading");
            var content = $('#contentSerch').val();
            var dealerName = $('#dealerNameSerch').val();
            var answer = $('#dealerAnswerSerch').val();
        	var type = $('#questionTypeSerch').combobox("getValue");
      		
            var service = $.svc.getSVC("/visit/getVisitAnswersPage");
            service.setPage(page, size)
            .setParam("content", content)
            .setParam("dealerName", dealerName)
            .setParam("type", type)
            .setParam("answer", answer);
            service.call(
                    function (response, status) {
                        if (response.getResult().length == '0') {
                            $('#dg_cr').datagrid("loadData", []);
                        } else {
                            $('#dg_cr').datagrid("loadData", response.getResult());
                        }
                        $('#dg_cr').datagrid("loaded");
                    });
        }
        //重置
        $('#resetSearch').click(function(){
        	$('#contentSerch').val(""); 
        	$('#dealerAnswerSerch').val(""); 
        	$('#dealerNameSerch').val(""); 
        	$('#questionTypeSerch').combobox('setValue','')
        	loadVisitAnswerPage();
        })
         
     // 删除
        function updateIsNormal() {
         	var row = $('#dg_cr').datagrid('getChecked');
             if (row == '') {
               $.messager.alert("提示信息", "请选择要人工拜访的数据！！！！", "error");
               return;
              }
             var id = row[0].id;
             var isNormal=row[0].isNormal;
             if(isNormal==1 || isNormal==3){
            	 $.messager.alert("提示信息", "请选择异常拜访的数据！！！！", "error");
                 return;
             }
             $.messager.confirm("操作提示", "您确定要执行操作吗？", function (data) {
               if (data) {
               	var service = $.svc.getSVC("/visit/updateIsNormal");
       	        service
       	        .setParam("visit/id", id);
       	        service.call(
                      function (data, status) {
                   	   if (data.succ == true) {
                        	  $.messager.alert('提示', '更新成功!', 'info');
                        	  loadVisitAnswerPage();
                          } else {
                              $.messager.alert('提示', '更新失败!', 'error');
                          }
                      });
               }
           });
           
       }

    </script>
</body>
</html>